<template>
  <div>
    <el-button type="primary" @click="getContract">Refresh</el-button>
    <div class="text-center pdf-content">
      <div ref="pdfCanvas"></div>
    </div>
  </div>
</template>

<script>
import { renderPdf } from '@/common/plugins/tools/pdf'

export default {
  components: {},
  props: {},
  data() {
    return {}
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    getContract() {
      this.$http({
        url: 'https://vimi8-dev.oss-cn-shenzhen.aliyuncs.com/credit/contract/letter-pdf-int8array.json',
        methods: 'get',
      }).then(res => {
        const arr = new Int8Array(res.data)
        // const buffer = new ArrayBuffer(29118)
        const blob = new Blob([arr], { type: 'application/pdf' })
        const url = window.URL.createObjectURL(blob)
        return renderPdf(this.$refs.pdfCanvas, url)
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.page-content {
  border: 1px solid $border-color;
  width: 794px;
  margin: 0 auto;
}
.pdf-content {
  min-height: 200px;
  margin: 0 auto;
}
</style>
